#include "VSConstValue.h"
#include "VSShaderStringFactory.h"
#include "VSGraphicInclude.h"
#include "VSStream.h"
using namespace VSEngine2;
IMPLEMENT_RTTI_NoCreateFun(VSConstValue,VSShaderFunction)
IMPLEMENT_INITIAL_NO_CLASS_FACTORY_BEGIN(VSConstValue)
IMPLEMENT_INITIAL_NO_CLASS_FACTORY_END
BEGIN_ADD_PROPERTY(VSConstValue,VSShaderFunction)
REGISTER_PROPERTY(m_bIsCustom,IsCustom,VSProperty::F_SAVE_LOAD_CLONE)
END_ADD_PROPERTY
VSConstValue::VSConstValue()
{

}
VSConstValue::VSConstValue(const VSUsedName & ShowName,VSMaterial * pMaterial,unsigned int uiValueNum,bool bIsCustom)
				:VSShaderFunction(ShowName,pMaterial)
{
	m_bIsCustom = bIsCustom;
}
VSConstValue::~VSConstValue()
{
}
unsigned int VSConstValue::DiskUse()const
{
	unsigned int Use = VSShaderFunction::DiskUse();
	Use += sizeof(bool);
	return Use;

}
bool VSConstValue::Save(VSStream & rStream,unsigned int &iSaveUse)const
{
	if(!VSShaderFunction::Save(rStream,iSaveUse))
		return false;

	if(!rStream.Write(&m_bIsCustom ,sizeof(bool)))
		return 0;
	iSaveUse += sizeof(bool);

	return 1;
}
bool VSConstValue::Load(VSStream & rStream,unsigned int &iSaveUse)
{

	if(!VSShaderFunction::Load(rStream,iSaveUse))
		return false;


	if(!rStream.Read(&m_bIsCustom ,sizeof(bool)))
		return 0;
	iSaveUse += sizeof(bool);

	return 1;

}
bool VSConstValue::Clone(const VSObject *pObject,unsigned int uiType)
{
	//NO USE
	const VSConstValue* Temp = DynamicCast<VSConstValue>(pObject); 
	if(!Temp)
		return 0;
	if(VSShaderFunction::Clone(pObject,uiType))
	{
		m_bIsCustom = Temp->m_bIsCustom;
		return 1;
	}
	else
	{
		return 0;

	}
}

